//
//  GenericityViewController.swift
//  SwiftTest
//
//  Created by midea on 16/3/21.
//  Copyright © 2016年 Vincent. All rights reserved.
//

import Foundation

struct IntStack {
    var intItems = Array.init(repeating: 0, count: 0)
    mutating func push(_ item : Int) {
        intItems.append(item)
    }
    mutating func pop() -> Int {
        return intItems.removeLast()
    }
}

class GenericityViewController : BaseViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        statement()
        
        
    }
    
    fileprivate func statement(){
        
        var int1 = 1
        var int2 = 5
        GenericityViewController.swapTwoValues(&int1, b: &int2)
        print("int1 is " + String(int1))
        print("int2 is " + String(int2))
        
        var string1 = "hello"
        var string2 = "world"
        GenericityViewController.swapTwoValues(&string1, b: &string2)
        print("string1 is " + string1)
        print("string2 is " + string2)
    }
    
    class func swapTwoValues<T>(_ a: inout T, b: inout T) {
        let temporaryA = a
        a = b
        b = temporaryA
    }
    
    
}
